package com.lanou.sfu.songforu.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.lanou.sfu.songforu.R;
import com.lanou.sfu.songforu.datas.SearchHotDatas;

import java.util.List;

/**
 * Created by quyan on 15/10/28.
 */
public class SearchHotAdapter extends BaseAdapter {
    private List<SearchHotDatas.DataEntity> datas;
    private Context context;

    public SearchHotAdapter(Context context, List<SearchHotDatas.DataEntity> dataEntities) {
        this.context = context;
        datas = dataEntities;
    }

    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.fragment_search_gridviewitem,null);
            holder = new ViewHolder();
            holder.textView = (TextView) convertView.findViewById(R.id.hotSecrchText);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        SearchHotDatas.DataEntity dataEntity = (SearchHotDatas.DataEntity) getItem(position);
        Log.i("chengxinghe",dataEntity.getVal() + " ");
        holder.textView.setText(dataEntity.getVal());
        return convertView;
    }
    public class ViewHolder{
        private TextView  textView;
    }
}
